package cn.buk.tms.entity.misc;

import cn.buk.tms.entity.base.BaseInfo;

import jakarta.persistence.*;

import static cn.buk.tms.common.constant.TmsConstant.FLIGHT_AUTO_TICKETING_NONE;

/**
 * 供应商信息
 * @author yfdai
 */
@Entity
@Table(name="ent_supplier",
        uniqueConstraints = @UniqueConstraint(
                name = "uk_supplier",
                columnNames = {"enterprise_id", "name"}))
public class Supplier extends BaseInfo {

    /**
     * 供应商名称，不能重复
     */
    @Column(length = 30)
    private String name;

    /**
     * 供应商类型
     * 0-综合
     * 1-机票
     * 2-保险
     * 3-酒店
     * 4-旅游
     * 5-火车票
     * @see cn.buk.tms.common.constant.TmsOrderConstant
     */
    @Column(name = "supplier_type")
    private int supplierType;

    /**
     * 拼音，用于排序,和检索
     */
    @Column(length = 10)
    private String pinyin;

    /**
     * 状态
     * 0： 停用
     * 1/null: 启用
     */
    private Integer status;

    /**
     * 是否为默认供应商，只允许有一个默认供应商
     */
    @Column(name = "is_default")
    private Integer isDefault;

    /**
     * 是否BSP供应商(GP也算广义的BSP)
     */
    @Column(name = "is_bsp")
    private Integer isBsp;

    /**
     * 默认的支出付款方式id
     */
    @Column(name = "payment_method_id")
    private Integer paymentMethodId;

    /**
     * 使用频率
     */
    private Integer frequency;

    private String remark;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public int getSupplierType() {
        return supplierType;
    }

    public void setSupplierType(int supplierType) {
        this.supplierType = supplierType;
    }

    public Integer getStatus() {
        return status == null ? 1 : status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getPinyin() {
        return pinyin;
    }

    public void setPinyin(String pinyin) {
        if (pinyin != null) {
            pinyin = pinyin.trim().toUpperCase();
        }
        this.pinyin = pinyin;
    }

    public int getPaymentMethodId() {
        return paymentMethodId == null ? 0 : paymentMethodId;
    }

    public void setPaymentMethodId(Integer paymentMethodId) {
        this.paymentMethodId = paymentMethodId;
    }

    public int getIsDefault() {
        return isDefault == null ? 0 : isDefault;
    }

    public void setIsDefault(int isDefault) {
        this.isDefault = isDefault;
    }

    /**
     * 该供应商是否为BSP，如果是BSP则可以自动开票
     */
    public int getIsBsp() {
        return isBsp == null ? FLIGHT_AUTO_TICKETING_NONE : isBsp;
    }

    public void setIsBsp(int isBsp) {
        this.isBsp = isBsp;
    }

    public Integer getFrequency() {
        return frequency;
    }

    public void setFrequency(Integer frequency) {
        this.frequency = frequency;
    }
}
